<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>添加页面</title>
    <th:block th:include="material/core/resources::headers"/>
</head>

<body>
<div class="layui-fluid">
    <div class="layui-row">
        <form class="layui-form" id="MaterialFrom" name="MaterialFrom" th:object="${materialInfo}">

            <input type="hidden" name="id" th:value="*{id}" />

            <div class="layui-form-item">
                <label for="num" class="layui-form-label">
                    <span class="x-red"></span>物料编号：
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="num" name="num" required="" lay-verify="required"
                           autocomplete="off" class="layui-input" th:value="*{num}">
                </div>
            </div>
            <div class="layui-form-item">
                <label for="type" class="layui-form-label">
                    <span class="x-red"></span>物料类型：
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="type" name="type" required="" lay-verify="required"
                           autocomplete="off" class="layui-input" th:value="*{type}">
                </div>
            </div>
            <div class="layui-form-item">
                <label for="status" class="layui-form-label">
                    <span class="x-red"></span>物料状态：
                </label>
                <div class="layui-input-inline">
                    <select id="status">
                        <option value="1">充足</option>
                        <option value="2">正常</option>
                        <option value="3">短缺</option>
                    </select>
                </div>
            </div>
            <div class="layui-form-item">
                <label for="quantity" class="layui-form-label">
                    <span class="x-red"></span>剩余数量：
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="quantity" name="quantity" required="" lay-verify="required"
                           autocomplete="off" class="layui-input" th:value="*{quantity}">
                </div>
            </div>
<!--            <div class="layui-form-item">-->
<!--                <label for="remark" class="layui-form-label">-->
<!--                    <span class="x-red"></span>备注：-->
<!--                </label>-->
<!--                <div class="layui-input-inline" style="width: 400px" th:value="*{remark}">-->
<!--                    <textarea id="remark" style="display: none;"></textarea>-->
<!--                </div>-->
<!--            </div>-->
            <div class="layui-form-item" style="padding-left: 110px">
                <button class="layui-btn" lay-filter="update" lay-submit="">
                    修改
                </button>
                <button class="layui-btn" type="reset">
                    重置
                </button>
            </div>

        </form>

    </div>
</div>

</body>

<script>layui.use(['form', 'layer', 'jquery'],
    function () {
        const $ = layui.jquery;
        const form = layui.form, layer = layui.layer;
        form.on('submit(update)',
            function (data) {
                $.ajax({
                    url: "/materInfo/updateInfo",
                    type: "post",
                    data: data.field,
                    success(res) {
                        if (res.success) {
                            layer.alert("修改成功啊🐇", {
                                    icon: 6
                                },
                                function () {
                                    xadmin.close();
                                    xadmin.father_reload();
                                });
                        } else {
                            layer.msg(res.msg)
                        }
                    }
                })
                return false;
            });
    });
</script>

<script th:inline="javascript">
    if([[${materialInfo.state}]] == "\u5145\u8DB3"){
        var select = 'dd[lay-value="1"]';
        $('#status').siblings("div.layui-form-select").find('dl').find(select).click();
    }
    if([[${materialInfo.state}]] == "\u6B63\u5E38"){
        var select = 'dd[lay-value="2"]';
        $('#status').siblings("div.layui-form-select").find('dl').find(select).click();
    }
</script>
</html>